package com.atguigui.leetcode1;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 1023.驼峰式匹配
 * Project: leetcode
 * Package: com.atguigui.leetcode1
 * Version: 1.0
 * <p>
 * Created by WJX on 2023/4/14 9:36
 */
public class P1023CamelcaseMatching {
    public static void main(String[] args) {
        Solution solution = new P1023CamelcaseMatching().new Solution();
        // TO TEST
    }

    class Solution {
        public List<Boolean> camelMatch(String[] queries, String pattern) {
            StringBuilder regexp = new StringBuilder("[a-z]*");
            for (int i = 0; i < pattern.length(); i++) {
                //将字符和正则表达式 "[a-z]" 拼接起来
                regexp.append(pattern.charAt(i)).append("[a-z]*");
            }
            //匹配零个或多个大写字母
            return Arrays.stream(queries).map(query -> query.matches(regexp.toString())).collect(Collectors.toList());
        }
    }
}
